import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../util/common.dart';
import '../../../widgets/text_button.dart';
import '../../../widgets/yz_text.dart';
import 'md5_helper_controller.dart';
// import 'package:desktop_drop/desktop_drop.dart';

class Md5HelperPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetX<Md5HelperController>(
        init: Md5HelperController(),
        builder: (controller) {
          return Scaffold(
            appBar: AppBar(
              title: Text('MD5'),
            ),
            body:
              // DropTarget(
            //     onDragDone: (detail) {
            //       controller.filePath.value = detail.files[0].path;
            //     },
            //     onDragEntered: (detail) {
            //       // 拖拽进入
            //     },
            //     onDragExited: (detail) {
            //       // 拖拽离开
            //     },
            //     child:
                Container(
                    height: windowHeight,
                    margin: EdgeInsets.symmetric(horizontal: 15),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Column(
                          children: [
                            MyTextField(
                              controller: controller.textEditingController,
                              width: 300,
                              height: 90,
                              hintText: '请输入需要转换的字符串',
                            ),
                            controller.filePath.isEmpty
                                ? MyTextButton(
                                    text: "添加文件",
                                    height: 25,
                                    backgroundColor: Colors.transparent,
                                    sideColor: Colors.transparent,
                                    textStyle: TextStyle(color: Colors.teal),
                                    margin: EdgeInsets.only(left: 15),
                                    confirm: () {
                                      controller.chooseFile();
                                    },
                                  )
                                : Text(
                                    controller.filePath.value,
                                    style: TextStyle(color: Colors.teal),
                                  ),
                          ],
                        ),
                        Column(
                          children: [
                            textButton('MD5', onPressed: () {
                              controller.encode(1);
                            }),
                            textButton('SHA-1', onPressed: () {
                              controller.encode(2);
                            }),
                            textButton('SHA-256', onPressed: () {
                              controller.encode(3);
                            }),
                          ],
                        ),
                        Expanded(
                            child: Container(
                          height: windowHeight * 0.8,
                          margin: EdgeInsets.only(top: 10),
                          padding: EdgeInsets.only(top: 10),
                          child: TextField(
                            controller: controller.resultEditingController,
                            readOnly: true,
                            decoration: InputDecoration(
                              border: const OutlineInputBorder(),
                            ),
                            maxLines: null,
                            style: TextStyle(color: Colors.green),
                          ),
                        ))
                      ],
                    ))
          // ),
          );
        });
  }
}
